#ifndef SKYID_SOUND_H 
#define SKYID_SOUND_H

#include <AL/al.h>
#include <AL/alc.h>
#include <ogg/ogg.h>
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>

#include "common.h"
#include "object.h"
#include "reader.h"

namespace SkyID 
{

//- Sound ---------------------------------------------------------------------

class Sound : public Object
{
public:
	Sound();
	virtual ~Sound();

	virtual void play();
	virtual void stop();
	virtual void pause();

	virtual bool isPlaying() const;
	virtual bool isPaused() const;

protected:
	virtual bool open(Reader *reader) { return false; }
	bool check() const;

protected:
	ALuint mID;
	ALenum mFormat;
	ALsizei mFrequency;
	ALuint *mBuffer;
}; //tolua_export

//- SoundWAV ------------------------------------------------------------------

class SoundWAV : public Sound
{
public:
	SoundWAV(Reader *reader);
	~SoundWAV();

protected:
	bool open(Reader *reader);
};

//- SoundOGG ------------------------------------------------------------------

//tolua_begin
class SoundOGG : public Sound
{
public:
	SoundOGG(Reader *reader);
	~SoundOGG();

protected:
	bool open(Reader *reader);
};

//- Common -------------------------------------------------------------------

size_t HelperOggRead(void *ptr, size_t size, size_t nmemb, void *datasource);

} // namespace SkyID

#endif // SKYID_SOUND_H
